package app.r_teenus.frontend.controller;


import org.springframework.binding.message.MessageBuilder;
import org.springframework.binding.message.MessageContext;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import app.r_teenus.backend.model.Enterprise;


@Component
public class EnterpriseValidator {

	/**
	 * Spring Web Flow activated validation (validate + ${state}). Validates 'enterpriseForm' view state after binding to person.
	 */
	public void validateEnterpriseForm(Enterprise enterprise, MessageContext context) {
		if (!StringUtils.hasText(enterprise.getName())) {
			context.addMessage(new MessageBuilder().error().source("name").code("enterprise.form.name.required").build());
		} 
	}
}
